import { mappingNames, mappingValues, pixelFormatNames, pixelFormatValues, Texture, textureDataTypeNames, textureDataTypeValues, textureEncodingNames, textureEncodingValues, textureFilterNames, textureFilterValues, wrappingNames, wrappingValues } from "../../thirdparty/three/imports";

export class Texture3D
{
    /**
     * @private
     */
    get _texture()
    {
        return this.__texture;
    }
    set _texture(v)
    {
        Texture3D._map.delete(this.__texture);
        this.__texture = v;
        Texture3D._map.set(this.__texture, this);
    }
    /**
     * @private
     */
    __texture: Texture;

    get image()
    {
        return this._texture.image;
    }
    set image(v)
    {
        this._texture.image = v;
    }

    get wrapS()
    {
        return wrappingNames[this._texture.wrapS];
    }
    set wrapS(v)
    {
        this._texture.wrapS = wrappingValues[v];
    }

    get wrapT()
    {
        return wrappingNames[this._texture.wrapT];
    }
    set wrapT(v)
    {
        this._texture.wrapT = wrappingValues[v];
    }

    get anisotropy()
    {
        return this._texture.anisotropy;
    }
    set anisotropy(v)
    {
        this._texture.anisotropy = v;
    }

    get minFilter()
    {
        return textureFilterNames[this._texture.minFilter];
    }
    set minFilter(v)
    {
        this._texture.minFilter = textureFilterValues[v];
    }

    get magFilter()
    {
        return textureFilterNames[this._texture.magFilter];
    }
    set magFilter(v)
    {
        this._texture.magFilter = textureFilterValues[v];
    }

    get format()
    {
        return pixelFormatNames[this._texture.format];
    }
    set format(v)
    {
        this._texture.format = pixelFormatValues[v];
    }

    get type()
    {
        return textureDataTypeNames[this._texture.type];
    }
    set type(v)
    {
        this._texture.type = textureDataTypeValues[v];
    }

    get mapping()
    {
        return mappingNames[this._texture.mapping];
    }
    set mapping(v)
    {
        this._texture.mapping = mappingValues[v];
    }

    get needsUpdate()
    {
        return this._texture.needsUpdate;
    }
    set needsUpdate(v)
    {
        this._texture.needsUpdate = v;
    }

    get repeat()
    {
        return this._texture.repeat;
    }
    set repeat(v)
    {
        this._texture.repeat = v;
    }

    get encoding()
    {
        return textureEncodingNames[this._texture.encoding];
    }
    set encoding(v)
    {
        this._texture.encoding = textureEncodingValues[v];
    }

    static get(texture: Texture)
    {
        let texture3D = this._map.get(texture);
        if (!texture3D)
        {
            texture3D = new Texture3D();
            texture3D._texture = texture;
        }

        return texture3D;
    }
    protected static _map = new Map<Texture, Texture3D>();
}
